package 线程的状态;

public class joinApply {
    private static int a = 0;
    public static void main(String[] args) throws InterruptedException {
        System.out.println(Thread.currentThread() + "开始");
        Thread t1 = new Thread(()->{
            System.out.println(Thread.currentThread() + "开始");
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            a = 20;
            System.out.println(Thread.currentThread() + "结束");
        },"t1");
        t1.start();
        t1.join();//等待t1线程执行结束-->谁调用的就等谁结束
        System.out.println("a的结果 : " + a);
    }
}
